{{ if isset .Params "github" }}

{{ $upleft := .Site.Data.Modules.GithubRibbons.Upleft }}
{{ $upright := .Site.Data.Modules.GithubRibbons.Upright }}
{{ $.Scratch.Set "img" .Site.Data.Modules.GithubRibbons.Default }}
{{ $ribbon := .Params.ghribbon }}
{{ $.Scratch.Set "pos" "upright" }}

{{ if or ( eq $ribbon "black" ) ( eq $ribbon "black-upright" ) }}
  {{ $.Scratch.Set "img" $upright.Black }}
{{ else if or ( eq $ribbon "green" ) ( eq $ribbon "green-upright" ) }}
  {{ $.Scratch.Set "img" $upright.Green }}
{{ else if or ( eq $ribbon "grey" ) ( eq $ribbon "grey-upright" ) }}
  {{ $.Scratch.Set "img" $upright.Grey }}
{{ else if or ( eq $ribbon "orange" ) ( eq $ribbon "orange-upright" ) }}
  {{ $.Scratch.Set "img" $upright.Orange }}
{{ else if or ( eq $ribbon "red" ) ( eq $ribbon "red-upright" ) }}
  {{ $.Scratch.Set "img" $upright.Red }}
{{ else if or ( eq $ribbon "white" ) ( eq $ribbon "white-upright" ) }}
  {{ $.Scratch.Set "img" $upright.White }}
{{ end }}

{{ if eq $ribbon "black-upleft" }}
  {{ $.Scratch.Set "img" $upleft.Black }}
  {{ $.Scratch.Set "pos" "upleft" }}
  {{ $.Scratch.Set "left" "true" }}
{{ else if eq $ribbon "green-upleft" }}
  {{ $.Scratch.Set "img" $upleft.Green }}
  {{ $.Scratch.Set "pos" "upleft" }}
{{ else if eq $ribbon "grey-upleft" }}
  {{ $.Scratch.Set "img" $upleft.Grey }}
  {{ $.Scratch.Set "pos" "upleft" }}
{{ else if eq $ribbon "orange-upleft" }}
  {{ $.Scratch.Set "img" $upleft.Orange }}
  {{ $.Scratch.Set "pos" "upleft" }}
{{ else if eq $ribbon "red-upleft" }}
  {{ $.Scratch.Set "img" $upleft.Red }}
  {{ $.Scratch.Set "pos" "upleft" }}
{{ else if eq $ribbon "white-upleft" }}
  {{ $.Scratch.Set "img" $upleft.White }}
  {{ $.Scratch.Set "pos" "upleft" }}
{{ end }}

{{ with .Params.github }}
<a class="ribbon git {{ $.Scratch.Get "pos" }}" href="https://github.com/{{ . }}">
  <img
    src="{{ $.Scratch.Get "img" }}"
    alt="Fork me on GitHub">
</a>
{{ end }}

{{ end }}
